package offer;

import java.util.ArrayDeque;
import java.util.Deque;

class CQueue {
    Deque<Integer> stack;
    Deque<Integer> queue;

    public CQueue() {
        stack = new ArrayDeque<>();
        queue = new ArrayDeque<>();
    }

    public void appendTail(int value) {
        stack.push(value);
    }

    public int deleteHead() {
        if (queue.isEmpty()) {
            while (!stack.isEmpty()) {
                queue.push(stack.pop());
            }
        }
        return queue.isEmpty() ? -1 : queue.pop();
    }
}
